import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

/**
 * Tests correctness of closing shapes
 */
class ShapeClosing extends Sprite
{
    public function new()
    {
        super();
        neash.Lib.current.addChild( this );
 

        //Fully closed shape
        graphics.lineStyle(1,0xFFFFFF);
        graphics.beginFill(0x00ff00);
        graphics.moveTo( 50, 250 );
        graphics.lineTo( 100, 250 );
        graphics.lineTo( 100, 300 );
        graphics.lineTo( 50, 300 );
        graphics.lineTo( 50, 250 );
        graphics.endFill();


        //Fully closed shape, but with "moveTo" in it
        // This should generate a funny shape..
        graphics.lineStyle(1,0xFFFFFF);
        graphics.beginFill(0x00ff00);
        graphics.moveTo( 250, 250 );
        graphics.lineTo( 300, 250 );
        graphics.moveTo( 300, 300 );
        graphics.lineTo( 250, 300 );
        graphics.lineTo( 250, 250 );
        graphics.endFill();



        //Fully closed shape, some "invisible" lines
        graphics.lineStyle(1,0xFFFFFF);
        graphics.beginFill(0x00ff00);
        graphics.moveTo( 150, 250 );
        graphics.lineTo( 200, 250 );
        graphics.lineTo( 200, 300 );
        graphics.lineStyle(null);
        graphics.lineTo( 150, 300 );
        graphics.lineTo( 150, 250 );
        graphics.endFill();


        //simply unclosed shape
        graphics.lineStyle(1,0xFFFFFF);
        graphics.beginFill(0x800000);
        graphics.moveTo( 50, 50 );
        graphics.lineTo( 100, 50 );
        graphics.lineTo( 100, 100 );
        graphics.lineTo( 50, 100 );
        graphics.endFill();
        
        //half shape
        graphics.lineStyle(1,0xFFFFFF);
        graphics.beginFill(0x800000);
        graphics.moveTo( 150, 50 );
        graphics.lineTo( 200, 50 );
        graphics.lineTo( 200, 100 );
        graphics.endFill();


        // Changing line-style mid shape
        graphics.lineStyle(1,0xFFFFFF);
        graphics.beginFill(0x800000);
        graphics.moveTo( 150, 150 );
        graphics.lineTo( 200, 150 );
        // New line stype
        graphics.lineStyle(3,0xFFFFFF);
        graphics.lineTo( 200, 200 );

        // Change colour for the implicit end fill.
        graphics.lineStyle(1,0xFFFFFF);
        // Implicit "endFill" generated by "beginFill"

        graphics.beginFill(0x800000);
        graphics.moveTo( 50, 150 );
        graphics.lineTo( 100, 150 );
        graphics.lineTo( 100, 200 );
        graphics.lineTo( 50, 200 );
        // Implicit "endFill" at end of scope

    }
	
    static public function main()
    {
    	neash.Lib.Init("ShapeClosing",400,400);
    	neash.Lib.SetBackgroundColour(0x000000);
    	new ShapeClosing();
		neash.Lib.Run();
    }
}
